let optimization = require('./webpack.optimization')
let rules = require('./webpack.rules')
let plugins = require('./webpack.plugins')
let resolve = require('./webpack.resolve')
let output = require('./webpack.output')
let entry = require('./webpack.entry')

module.exports = (_env, _target) => {
    let env = (_env === 'prod' || _env === 'production') ? 'production' : 'development'
    let ispod = (env === 'production') ? true : false
    let target = (_target === 'node') ? 'node' : 'web'
    return {
        devtool: (ispod) ? false : 'source-map',
        mode: env,
        target: target,
        entry: entry(ispod, target),
        output: output(ispod, target),
        optimization: optimization(ispod, target),
        resolve: resolve(ispod, target),
        module: {
            rules: rules(ispod, target)
        },
        plugins: plugins(ispod, target)
    }
}
